<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="http://www.petercorke.com/RVC/common/toolboxhelp.css">
    <title>M-File Help: distance</title>
  </head>
  <body>
  <table border="0" cellspacing="0" width="100%">
    <tr class="subheader">
      <td class="headertitle">M-File Help: distance</td>
      <td class="subheader-left"><a href="matlab:open distance">View code for distance</a></td>
    </tr>
  </table>
<h1>distance</h1><p><span class="helptopic">Euclidean distances between sets of points</span></p><p>
<strong>d</strong> = <span style="color:red">distance</span>(<strong>a</strong>,<strong>b</strong>) is the Euclidean distances between L-dimensional points
described by the matrices <strong>a</strong> (LxM) and <strong>b</strong> (LxN) respectively.  The <span style="color:red">distance</span>
<strong>d</strong> is MxN and element <strong>d</strong>(I,J) is the <span style="color:red">distance</span> between points <strong>a</strong>(I) and <strong>d</strong>(J).

</p>
<h2>Example</h2>
<pre style="width: 90%%;" class="examples">
A&nbsp;=&nbsp;rand(400,100);&nbsp;B&nbsp;=&nbsp;rand(400,200);
d&nbsp;=&nbsp;distance(A,B);
</pre>
<h2>Notes</h2>
<ul>
  <li>This fully vectorized (VERY FAST!)</li>
  <li>It computes the Euclidean distance between two vectors by:</li>
</ul>
<pre style="width: 90%%;" class="examples">
||A-B||&nbsp;=&nbsp;sqrt&nbsp;(&nbsp;||A||^2&nbsp;+&nbsp;||B||^2&nbsp;-&nbsp;2*A.B&nbsp;)
</pre>
<h2>Author</h2>
<p>
Roland Bunschoten,
University of Amsterdam,
Intelligent Autonomous Systems (IAS) group,
Kruislaan 403  1098 SJ Amsterdam,
tel.(+31)20-5257524,
bunschot@wins.uva.nl
Last Rev: Oct 29 16:35:48 MET DST 1999,
Tested: PC Matlab v5.2 and Solaris Matlab v5.3,
Thanx: Nikos Vlassis.

</p>
<h2>See also</h2>
<p>
<a href="matlab:doc closest">closest</a></p>
<hr>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
  <tr class="subheader" valign="top"><td>&nbsp;</td></tr></table>
<p class="copy">&copy; 1990-2012 Peter Corke.</p>
</body></html>